package com.isoft.demo.controller;

import com.isoft.demo.common.ResponseData;
import com.isoft.demo.entity.Emp;
import com.isoft.demo.service.EmpService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@CrossOrigin
public class EmpController {
    @Resource
    private EmpService empService;

    @GetMapping("/addEmp")
    public ResponseData addEmp(Emp emp){
        ResponseData rs= empService.addEmp(emp);
        return rs;
    }
    @GetMapping("/updateEmp")
    public ResponseData updateEmp(Emp emp){
        ResponseData rs = empService.updateEmp(emp);
        return rs;
    }
    @GetMapping("/deleteEmp")
    public ResponseData deleteEmp(@Param(value = "eid") int eid){
        ResponseData rs = empService.deleteEmp(eid);
        return  rs;
    }
    @GetMapping("/allEmp")
    public ResponseData findAllEmp(){
        ResponseData rs= empService.findAllEmp();
        return rs;
    }
    @GetMapping("/byEid")
    public ResponseData findByEid(Integer eid){
        ResponseData rs = empService.findByEid(eid);
        return rs;
    }
}
